import styles from './styles.module.scss'
import Link from 'next/link'
import Image from '@/components/Image'
const url = process.env.NEXT_PUBLIC_URLPROXY
const Recommend = ({ data, style, link }) => {
  const imgUrl = (s) => {
    if (s?.newsImg) {
      return url + `?url=${s?.newsImg}`
    }
    return s?.coverImg || s?.videoImg || ''
  }
  if (data?.length === 0) return <></>
  return (
    <section style={style} className={styles.recommend}>
      <p>精彩推荐</p>
      <ul>
        {
          data?.map(row => (
            <Link href={link(row)} key={row?.id} >
              <a target="_blank" title={row?.newsTitle || row?.videoName}>
                <Image src={imgUrl(row)} alt={row?.newsTitle || row?.videoName} />
                <p>{row?.newsTitle || row?.title || row?.videoName}</p>
              </a>
            </Link>
          ))
        }
      </ul>
    </section>
  )
}


export default Recommend